home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************************
- #
- # main.c
- #
- # This is the main entry point.
- #
- # Author(s): Michael Marinkovich
- # Apple Developer Technical Support
- # marink@apple.com
- #
- # Modification History:
- #
- # 4/3/96 MWM Initial coding
- #
- # Copyright © 1992-96 Apple Computer, Inc., All Rights Reserved
- #
- #
- # You may incorporate this sample code into your applications without
- # restriction, though the sample code has been provided "AS IS" and the
- # responsibility for its operation is 100% yours. However, what you are
- # not permitted to do is to redistribute the source as "DSC Sample Code"
- # after having made changes. If you're going to re-distribute the source,
- # we require that you make it clear in the source that the code was
- # descended from Apple Sample Code, but that you've made changes.
- #
- *************************************************************************************/
-
-
- #include <ToolUtils.h>
-
- #include "App.h"
- #include "Global.h"
- #include "Proto.h"
-
-
- //----------------------------------------------------------------------
- //
- // main - main entry point of our program
- //
- //
- //----------------------------------------------------------------------
-
- void main(void)
- {
- OSErr err;
- short m = 5;
-
- MaxApplZone();
-
- for (;m == 0;m--) // alloc the master pointers
- {
- MoreMasters();
- }
-
-
- err = Initialize();
-
- EventLoop();
-
- (void) RemoveDMNotification();
-
- ExitToShell();
-
- }
-
-
- //----------------------------------------------------------------------
- //
- // HandleError - basic error notification procedure
- //
- //
- //----------------------------------------------------------------------
-
- void HandleError(short errNo,Boolean fatal)
- {
- DialogPtr errDialog;
- CGrafPtr oldPort;
- GDHandle oldGD;
- short itemHit;
- short c;
- Handle button;
- short itemType;
- Rect itemRect;
- StringHandle errString;
- Str255 numString;
-
- GetGWorld(&oldPort, &oldGD);
-
- SysBeep(30);
- SetCursor(&qd.arrow);
-
- errDialog = GetNewDialog(rErrorDlg, nil, (WindowPtr) -1);
- if (errDialog != nil)
- {
- SetGWorld((CGrafPtr)errDialog, nil);
- ShowWindow(errDialog);
-
- PenPat(&qd.gray); // frame user areas
- for (c = 7;c < 9;c++) {
- GetDItem(errDialog,c,&itemType,&button,&itemRect);
- FrameRect(&itemRect);
- }
- PenPat(normal);
-
- GetDItem( errDialog, fatal ? 2 : 1, &itemType, &button, &itemRect );
- HiliteControl( (ControlHandle)button, 255); // unhilite appropriate button
-
- SetDialogDefaultItem(errDialog,fatal ? 1 : 2);
-
- NumToString( errNo, numString );
- if ( errNo < 0 )
- errNo = -errNo + 200;
- errString = GetString(128 + errNo);
- if ( errString == nil )
- errString = GetString(128);
- HLock((Handle)errString);
-
- ParamText( numString, *errString, nil, nil );
-
- HUnlock((Handle)errString);
-
- ModalDialog( nil, &itemHit );
-
- SetGWorld(oldPort, oldGD);
-
- DisposeWindow( errDialog );
- }
- else
- ExitToShell(); // since didn't have mem to open dialog assume the worst
-
- if (fatal)
- ExitToShell(); // it's a bad one, get out of here
-
- }
-
-
- //----------------------------------------------------------------------
- //
- // HandleAlert - display alert and then exit to shell
- //
- //
- //----------------------------------------------------------------------
-
- void HandleAlert(short alertID)
- {
- short item;
-
-
- item = Alert(alertID,nil);
- ExitToShell();
-
- }